package com.shujia.szt;

import org.apache.hadoop.hive.ql.exec.UDF;

public class MakePassengersKey extends UDF {
    /**
     * 将A-B和B-A 转换成相同组合
     */
    public String evaluate(String Passengers) {
        String key;
        String[] split = Passengers.split("-");
        String in = split[0];
        String out = split[1];
        // 字符串比较大小
        if (in.compareTo(out) < 0) {
            key = in + "-" + out;
        } else {
            key = out + "-" + in;
        }
        return key;
    }

}
